<?php $this->layout('layout.php') ?>
<?php $this->title = 'My cart' ?>
<?php $this->noCartLayout=true;?>
<div data-ng-controller="ProductsController">
	<?php $this->insert('cart/cart.php');?>
	<h1>My Cart</h1>
	<hr/>
	<div id="subTotal">
        <form method="get" action="<?= $this->route('buy'); ?>">
            Subtotal ( {{ productCart.nbProduct }} robots ) : <span
                class="ourprice">{{ productCart.totalPrice }}€</span>
            <br/><br/>
            <input type="submit" value="Get your robots"/>
        </form>
	</div>
	<div id="cartView">
		<div class="item" data-ng-repeat='productItem in productCart.products'>
			<div class="itemContent">
				<img alt="imageRobot" src="nothing.jpg" data-ng-src="{{ productItem.product.img }}" class="imgCartDetails"/>
				<div class="info">
					<div class="price details"><span>Price: </span>{{ productItem.product.price }}€</div>
					<div class="number details"><span>Remaining:</span> {{ productItem.product.number }}</div>
					<div class="number details"><span>Estimated remaining:</span> {{ productItem.estimate }}</div>
					<form data-ng-submit="productCart.updateCart(productItem.product, productItem.qty, true)">
						<input type="button" value="+" class="plus" data-ng-click="productCart.updateCart(productItem.product, 1, 0)"/>
						<input type="text" data-ng-model='productItem.qty' data-ng-blur="productCart.updateCart(productItem.product, productItem.qty, true)" />
						<input type="button" value="-" class="moins" data-ng-click="productCart.updateCart(productItem.product, -1, 0)"/>
					</form>
				</div>
				<div class="content">
					<div class="title">{{ productItem.product.title }}</div>
					<p class="description">{{ productItem.product.description }}</p>
				</div>
			</div>
		</div>
		<hr/>
		<div class="recap">
		<span>Total price:</span> {{ productCart.totalPrice }}€
		</div>
	</div>
</div>
<script>
  $(document).ready(function(){
    $("#subTotal").sticky({topSpacing:25,className:"subTotalSticky"});
  });
</script>